/*
 * Account.java
 *
 * Created on 7 novembre 2007, 11:55
 */
package com.reimscopie ;

import java.util.* ;


/**
 * This object is a user account, without persistence.
 */
public class Account extends Value {
  
  // personal datas
  private String login ;
  private String password ;
  private String mail ;
  private boolean newsletter ;
  private float balance ;
  private PersonalInfo personalinfo ;
  
  
  /**
   * Create a new instance of <code>Account</code> with all attributes. This
   * object an no image in the database.
   *
   * @param login The account login.
   * @param password The account password.
   * @param mail The account mail.
   * @param newsletter The newsletter status of this account.
   * @param balance The user balance (money amount).
   * @param personalinfo The personal informations about the account owner.
   */
  public Account(String login,String password,String mail,boolean newsletter,
      float balance,PersonalInfo personalinfo) {
    
    super() ;
    
    this.login        = login ;
    this.password     = password ;
    this.mail         = mail ;
    this.newsletter   = newsletter ;
    this.balance      = balance ;
    this.personalinfo = personalinfo ;
    
  }
  
  
  /**
   * Create a new instance of <code>Account</code> with an image in the 
   * database.
   *
   * @param id The account id in the database.
   * @param login The account login.
   * @param password The account password.
   * @param mail The account mail.
   * @param newsletter The newsletter status of this account.
   * @param balance The user balance (money amount).
   * @param personalinfo The personal informations about the account owner.
   */
  public Account(long id,String login,String password,String mail,
      boolean newsletter,float balance,PersonalInfo personalinfo) {
    
    super(id) ;
    
    this.login        = login ;
    this.password     = password ;
    this.mail         = mail ;
    this.newsletter   = newsletter ;
    this.balance      = balance ;
    this.personalinfo = personalinfo ;
    
  }
  
  
  /**
   * Return the login name of this account.
   *
   * @return The account login.
   */
  public String getLogin() {
    return login ;
  }
  
  
  /**
   * Sets the login name of this account.
   *
   * @param login The new login name.
   */
  public void setLogin(String login) {
    this.login = login ;
  }
  
  
  /**
   * Return the personal informations about the account owner.
   *
   * @return The personal informations.
   */
  public PersonalInfo getPersonalInfo() {
    return personalinfo ;
  }
  
   /**
   * Sets the personalInfo of this account.
   *
   * @param personalinfo The new personalInfo.
   */
  public void setPersonalInfo(PersonalInfo personalinfo ) {
    this.personalinfo = personalinfo ;
  }
  
  
  /**
   * Return the password of this account.
   *
   * @return The account password.
   */
  public String getPassword() {
    return password ;
  }
  
    /**
   * Sets the password of this account.
   *
   * @param password The new password.
   */
  public void setPassword(String password) {
    this.password = password ;
  }
  
  
  /**
   * Return the mail address.
   *
   * @return The mail address.
   */
  public String getMail() {
    return mail ;
  }
  
  
  /**
   * Set the mail address.
   *
   * @param mail The new mail address.
   */
  public void setMail(String mail) {
    this.mail = mail ;
  }
  
  
  /**
   * Return the newsletter status of this account.
   *
   * @return The newsletter status of this account.
   */
  public boolean getNewsLetter() {
    return newsletter ;
  }
  
  
  /**
   * Set the newsletter status of this account.
   *
   * @param newsletter The newsletter status of this account.
   */
  public void setNewsLetter(boolean newsletter) {
    this.newsletter = newsletter ;
  }
  
  
  /**
   * Return the current balance of this account.
   *
   * @return The balance account (money ammount).
   */
  public float getBalance() {
    return balance ;
  }
  
  
  /**
   * Create a new map with all attributes of this value.
   *
   * @return A string-string map with the named attributes.
   */
  @Override
  public Map<String,String> toMap() {
    
    Map<String,String> map = new LinkedHashMap<String,String>() ;
    
    map.put("login",login) ;
    map.put("password",password) ;
    map.put("mail",mail) ;
    map.put("newsletter",String.valueOf(newsletter)) ;
    map.put("balance",String.valueOf(balance)) ;
    map.put("personalinfos",personalinfo.toString()) ;
    
    return map ;
    
  }
  
}
